package com.itheima.mapper;

import com.itheima.common.vo.ReportBusinessHotSetMealVo;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @className SetMealMapper
 */
@Mapper
public interface SetMealMapper {

    @Insert("insert into t_setmeal(name, code, helpCode, sex, age, price, remark, attention, img) VALUES " +
            "(#{name},#{code},#{helpCode},#{sex},#{age},#{price},#{remark},#{attention},#{img})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertSetMeal(Setmeal setMeal); //添加套餐

    void insertSetMealAndCheckGroupRelation(@Param("setMealId") Integer setMealId,
                                            @Param("checkGroupIds") List<Integer> checkGroupIds); //添加套餐和检查组的多对多关系

    void deleteSetMealAndCheckGroupRelation(Integer Id); //删除套餐和检查组的多对多关系

    @Delete("delete from t_setmeal where id = #{setMealId}")
    void deleteSetMealById(Integer setMealId); //删除套餐

    void updateSetMeal(Setmeal setMeal); //修改套餐

    @Select("select * from t_setmeal where id = #{setMealId}")
    Setmeal getSetMealById(Integer setMealId); //根据套餐id查询套餐

    List<Setmeal> selectSetMealByPage(String queryString); //分页查询套餐

    @Select("select name from t_setmeal")
    List<String> selectSetMealNames(); //查询所有套餐名称

    @Select("select count(id) from t_setmeal where name = #{setmealName}")
    Integer countSetMealByName(String setmealName); //根据套餐名称查询套餐数量

    List<ReportBusinessHotSetMealVo> selectSetMealsOrderCount(); //查询套餐预约统计

    @Select("select count(id) from t_setmeal")
    Integer selectSetMealCountTotal(); //查询套餐预约总数

    @Select("select * from t_setmeal")
    List<Setmeal> selectAllSetMeals(); //查询所有套餐

    Setmeal selectSetmealWithCheckGroupsAndItems(@Param("id") Integer setMealId);// 根据套餐id查询套餐信息和检查组信息和检查项信息
}
